<template>
  <div>
    <el-row class="tac">


      <el-menu
          router
          style="width: 200px; min-height: calc(100vh - 50px)"
          active-text-color="#ffd04b"
          background-color="#545c64"

          default-active="path"
          :default-openeds="[1]"
          text-color="#fff"
          class="el-menu-vertical-demo"

      >


<!--        <el-sub-menu index="1" v-if="this.rolelist.role ==='系统管理员'">-->
<!--          <template #title>系统管理</template>-->
          <el-menu-item :index="item.url" v-for="item in  this.sysmenulist"
                        :key="item.id" v-if="this.rolelist.role ==='系统管理员'"
          >{{ item.menuName }}
          </el-menu-item>
          <!--              <el-menu-item index="/role" >角色管理</el-menu-item>-->
          <!--              <el-menu-item index="/authority" >权限管理</el-menu-item>-->
<!--        </el-sub-menu>-->

          <el-menu-item :index="item.url" v-for="item in  this.shopmanage"
                        :key="item.id" v-if="this.rolelist.role ==='店长'"
          >{{ item.menuName }}
          </el-menu-item>


        <el-sub-menu index="5" v-if="this.rolelist.role ==='店长'">
          <template #title>餐厅座位管理</template>
          <el-menu-item :index="'/seatManage'">{{"座位管理"}}
          </el-menu-item>
          <el-menu-item :index="'/seatManage_available'">{{"当前可用座位"}}
          </el-menu-item>
          <el-menu-item :index="'/seatManage_using'">{{"使用中的桌位"}}
          </el-menu-item>
          <el-menu-item :index="'/seatManage_cleaning'">{{"需要打扫的桌位"}}
          </el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="2" v-if="this.rolelist.role ==='店长'">
          <template #title>订单管理</template>

          <el-menu-item :index="'/showOrder2'">{{"各桌位历史订单"}}
          </el-menu-item>
          <el-menu-item :index="'/TodayOrder'">{{"当日订单"}}
          </el-menu-item>
          <el-menu-item :index="'/showOrder_Running'">{{"进行中的订单"}}
          </el-menu-item>
          <el-menu-item :index="'/showOrder1'">{{"未支付订单"}}
          </el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="3" v-if="this.rolelist.role ==='店长'">
          <template #title>菜品管理</template>

          <el-menu-item :index="'/GoodsManage'">{{"查看菜品"}}
          </el-menu-item>
          <el-menu-item :index="'/goodsTypeManage'">{{"菜品分类管理"}}
          </el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="4" v-if="this.rolelist.role ==='店长'">
          <template #title>酒水管理</template>
          <el-menu-item :index="'/wineManage'">{{"查看酒水"}}
          </el-menu-item>
          <el-menu-item :index="'/wineTypeManage'">{{"酒水分类管理"}}
          </el-menu-item>
          <el-menu-item :index="'/wineStockManage'">{{"库存情况"}}
          </el-menu-item>
        </el-sub-menu>

        <el-sub-menu index="1" v-if="this.rolelist.role ==='店长'">

          <template #title>查看统计</template>
          <el-menu-item :index="'/statistics'">{{"菜品售出金额南丁格尔图"}}
          </el-menu-item>
          <el-menu-item :index="'/statistics1'">{{"各时间收入情况折线图"}}
          </el-menu-item>
          <el-menu-item :index="'/statistics2'">{{"各菜品销售数量占比饼图"}}
          </el-menu-item>
        </el-sub-menu>







<!--        <el-sub-menu index="3" v-if="this.rolelist.role ==='厨师'">-->
<!--          <template #title>厨师页面</template>-->
          <el-menu-item :index="item.url" v-for="item in  this.cooksmenu"
                        :key="item.id" v-if="this.rolelist.role ==='厨师'"
          >{{ item.menuName }}
          </el-menu-item>

<!--        </el-sub-menu>-->
<!--        <el-sub-menu index="4" v-if="this.rolelist.role ==='店员'">-->
<!--          <template #title>店员页面</template>-->
          <el-menu-item :index="item.url" v-for="item in  this.clerksmenu"
                        :key="item.id" v-if="this.rolelist.role ==='店员'"
          >{{ item.menuName }}
          </el-menu-item>
        <el-sub-menu index="7" v-if="this.rolelist.role ==='店员'">
          <template #title>点餐选座</template>
          <el-menu-item :index="'/showSeat_available_clerk'">{{"当前可用桌位"}}
          </el-menu-item>
          <el-menu-item :index="'/ShowSeat_using_clerk'">{{"正在使用的桌位"}}
          </el-menu-item>
          <el-menu-item :index="'/showSeat_need_clean_clerk'">{{"需要打扫的桌位"}}
          </el-menu-item>
<!--          <el-menu-item :index="'/showSeat_cleaning_clerk'">{{"需要打扫的桌位"}}-->
<!--          </el-menu-item>-->
        </el-sub-menu>
        <el-sub-menu index="8" v-if="this.rolelist.role ==='店员'">
          <template #title>排队取号</template>
          <el-menu-item :index="'/callNumber'">{{"正在排队的客人"}}
          </el-menu-item>
          <el-menu-item :index="'/callNumber_finish'">{{"已经进店的客人"}}
          </el-menu-item>
<!--          <el-menu-item :index="'/showSeat_need_clean_clerk'">{{"需要打扫的桌位"}}-->
<!--          </el-menu-item>-->
<!--          <el-menu-item :index="'/showSeat_cleaning_clerk'">{{"需要打扫的桌位"}}-->
<!--          </el-menu-item>-->
        </el-sub-menu>
        <el-sub-menu index="6" v-if="this.rolelist.role ==='店员'">
          <template #title>查看订单</template>
          <el-menu-item :index="'/showOrder_Running'">{{"进行中的订单"}}
          </el-menu-item>
          <el-menu-item :index="'/showOrder1'">{{"未支付订单"}}
          </el-menu-item>
          <el-menu-item :index="'/showOrder2'">{{"历史订单"}}
          </el-menu-item>
        </el-sub-menu>

<!--        </el-sub-menu>-->
<!--        <el-sub-menu index="5" v-if="this.rolelist.role ==='保洁'">-->
<!--          <template #title>保洁员页面</template>-->
          <el-menu-item :index="item.url" v-for="item in  this.cleanermenu"
                        :key="item.id" v-if="this.rolelist.role ==='保洁'"
          >{{ item.menuName }}
          </el-menu-item>

<!--        </el-sub-menu>-->

       


      </el-menu>

    </el-row>
  </div>
</template>

<script>
import request from "../utils/request";

export default {

  name: "Aside",
  data() {

    return {
      path: this.$router.path,
      rolelist: [],
      sysmenulist: [],
      shopmanage: [],
      cooksmenu: [],
      clerksmenu: [],
      cleanermenu: [],

    }
  },
  created() {
    this.load()
  },
  methods: {





    load() {


      let userJson1 = sessionStorage.getItem("user")
      this.rolelist = JSON.parse(userJson1)//转成字符串
  let role  =this.rolelist.role
      console.log(role)
      request.get("/menu/showMenu",{
      params:{role:role

      }
      }).then(res1 => {

        if (this.rolelist.role === '店长') {
          this.shopmanage = res1.data
        } else if (this.rolelist.role === '系统管理员') {
          this.sysmenulist = res1.data
        }else if (this.rolelist.role === '厨师') {
          this.cooksmenu = res1.data
        }else if (this.rolelist.role === '店员') {
          this.clerksmenu = res1.data
        }else if (this.rolelist.role === '保洁') {
          this.cleanermenu = res1.data
        }



      })


    },


  }
}
</script>

<style scoped>

</style>